import "package:flutter/material.dart";
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:get_it/get_it.dart';
import 'package:todo_app_open_source/controller/controller.dart';

class Header extends StatefulWidget {
  @override
  _HeaderState createState() => _HeaderState();
}

class _HeaderState extends State<Header> {
  final controller = GetIt.I.get<Controller>();
  Color headerTextColor2 = Color(0xD3D8E0);
  Color headerTextColor = Color(0xFF3A4068);
  get mediaQuery => MediaQuery.of(context).size;

  @override
  Widget build(BuildContext context) {
    return Observer(
      builder: (context) {
        return Column(children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Expanded(
                child: AutoSizeText(
                  "每日清单",
                  maxLines: 1,
                  style: TextStyle(
                      fontSize: mediaQuery.width * 0.08,
                      color: controller.secondColorApp,
                      fontWeight: FontWeight.bold),
                ),
              ),
              Switch(
                  onChanged: (value) {
                    controller.updateThemeApp(value);
                  },
                  value: controller.clearMode)
            ],
          ),
          Row(
            children: <Widget>[
              Text(
                "你有",
                style: TextStyle(color: Colors.grey),
              ),
              Text(
                  controller.myTasks.length == 1
                      ? "${controller.myTasks.length}任务"
                      : "${controller.myTasks.length}任务",
                  style: TextStyle(color: controller.secondColorApp)),
              Text("需要完成", style: TextStyle(color: Colors.grey))
            ],
          )
        ]);
      },
    );
  }
}
